#include <bits/stdc++.h>
using namespace std;
long long n, L, R;
int main() {
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout);
	cin >> n >> L >> R;
	long long r = R % n;
	if (R - r - 1 >= L) cout << n - 1 << endl;
	else cout << r << endl;
	return 0;
}
